namespace rptDataSetTableAdapters
{
    using System;
    using System.CodeDom.Compiler;
    using System.ComponentModel;
    using System.ComponentModel.Design;
    using System.Configuration;
    using System.Data;
    using System.Data.Common;
    using System.Data.SqlClient;
    using System.Diagnostics;

    [DesignerCategory("code"), GeneratedCode("System.Data.Design.TypedDataSetGenerator", "2.0.0.0"), HelpKeyword("vs.data.TableAdapter"), ToolboxItem(true), DataObject(true), Designer("Microsoft.VSDesigner.DataSource.Design.TableAdapterDesigner, Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
    public class DoanhNghiepTableAdapter : Component
    {
        private SqlDataAdapter _adapter;
        private bool _clearBeforeFill;
        private SqlCommand[] _commandCollection;
        private SqlConnection _connection;

        [DebuggerNonUserCode]
        public DoanhNghiepTableAdapter()
        {
            this.ClearBeforeFill = true;
        }

        [HelpKeyword("vs.data.TableAdapter"), DataObjectMethod(DataObjectMethodType.Fill, true), DebuggerNonUserCode]
        public virtual int Fill(rptDataSet.DoanhNghiepDataTable dataTable)
        {
            this.Adapter.SelectCommand = this.CommandCollection[0];
            if (this.ClearBeforeFill)
            {
                dataTable.Clear();
            }
            return this.Adapter.Fill(dataTable);
        }

        [DebuggerNonUserCode, HelpKeyword("vs.data.TableAdapter"), DataObjectMethod(DataObjectMethodType.Select, true)]
        public virtual rptDataSet.DoanhNghiepDataTable GetData()
        {
            this.Adapter.SelectCommand = this.CommandCollection[0];
            rptDataSet.DoanhNghiepDataTable dataTable = new rptDataSet.DoanhNghiepDataTable();
            this.Adapter.Fill(dataTable);
            return dataTable;
        }

        [DebuggerNonUserCode]
        private void InitAdapter()
        {
            this._adapter = new SqlDataAdapter();
            DataTableMapping mapping = new DataTableMapping();
            mapping.SourceTable = "Table";
            mapping.DataSetTable = "DoanhNghiep";
            mapping.ColumnMappings.Add("ma_doanh_nghiep", "ma_doanh_nghiep");
            mapping.ColumnMappings.Add("tai_khoan", "tai_khoan");
            mapping.ColumnMappings.Add("ten_doanh_nghiep", "ten_doanh_nghiep");
            mapping.ColumnMappings.Add("ten_tat", "ten_tat");
            mapping.ColumnMappings.Add("ten_so_huu", "ten_so_huu");
            mapping.ColumnMappings.Add("dia_chi", "dia_chi");
            mapping.ColumnMappings.Add("dia_chi_chi_tiet", "dia_chi_chi_tiet");
            mapping.ColumnMappings.Add("nguoi_lien_he", "nguoi_lien_he");
            mapping.ColumnMappings.Add("chuc_vu", "chuc_vu");
            mapping.ColumnMappings.Add("dien_thoai", "dien_thoai");
            mapping.ColumnMappings.Add("fax", "fax");
            mapping.ColumnMappings.Add("email", "email");
            mapping.ColumnMappings.Add("ma_so_thue", "ma_so_thue");
            mapping.ColumnMappings.Add("thanh_pho", "thanh_pho");
            this._adapter.TableMappings.Add(mapping);
        }

        [DebuggerNonUserCode]
        private void InitCommandCollection()
        {
            this._commandCollection = new SqlCommand[] { new SqlCommand() };
            this._commandCollection[0].Connection = this.Connection;
            this._commandCollection[0].CommandText = "SELECT        DoanhNghiep_doanh_nghiep.ma_doanh_nghiep, DoanhNghiep_doanh_nghiep.tai_khoan, DoanhNghiep_doanh_nghiep.ten_doanh_nghiep, \r\n                         DoanhNghiep_doanh_nghiep.ten_tat, DanhMuc_so_huu.ten_so_huu, dbo.fcGetDiaChiChiTiet(DoanhNghiep_doanh_nghiep.ma_dia_chi) AS dia_chi, \r\n                         dbo.fcGetThanhPho(DoanhNghiep_doanh_nghiep.ma_dia_chi) AS thanh_pho, DoanhNghiep_doanh_nghiep.dia_chi_chi_tiet, \r\n                         DoanhNghiep_doanh_nghiep.nguoi_lien_he, DoanhNghiep_doanh_nghiep.chuc_vu, DoanhNghiep_doanh_nghiep.dien_thoai, DoanhNghiep_doanh_nghiep.fax, \r\n                         DoanhNghiep_doanh_nghiep.email, DoanhNghiep_doanh_nghiep.ma_so_thue\r\nFROM            DoanhNghiep_doanh_nghiep INNER JOIN\r\n                         DanhMuc_so_huu ON DanhMuc_so_huu.ma_so_huu = DoanhNghiep_doanh_nghiep.ma_so_huu";
            this._commandCollection[0].CommandType = CommandType.Text;
        }

        [DebuggerNonUserCode]
        private void InitConnection()
        {
            this._connection = new SqlConnection();
            this._connection.ConnectionString = ConfigurationManager.ConnectionStrings["SLD_testConnectionString"].ConnectionString;
        }

        [DebuggerNonUserCode]
        private SqlDataAdapter Adapter
        {
            get
            {
                if (this._adapter == null)
                {
                    this.InitAdapter();
                }
                return this._adapter;
            }
        }

        [DebuggerNonUserCode]
        public bool ClearBeforeFill
        {
            get
            {
                return this._clearBeforeFill;
            }
            set
            {
                this._clearBeforeFill = value;
            }
        }

        [DebuggerNonUserCode]
        protected SqlCommand[] CommandCollection
        {
            get
            {
                if (this._commandCollection == null)
                {
                    this.InitCommandCollection();
                }
                return this._commandCollection;
            }
        }

        [DebuggerNonUserCode]
        internal SqlConnection Connection
        {
            get
            {
                if (this._connection == null)
                {
                    this.InitConnection();
                }
                return this._connection;
            }
            set
            {
                this._connection = value;
                if (this.Adapter.InsertCommand != null)
                {
                    this.Adapter.InsertCommand.Connection = value;
                }
                if (this.Adapter.DeleteCommand != null)
                {
                    this.Adapter.DeleteCommand.Connection = value;
                }
                if (this.Adapter.UpdateCommand != null)
                {
                    this.Adapter.UpdateCommand.Connection = value;
                }
                for (int i = 0; i < this.CommandCollection.Length; i++)
                {
                    if (this.CommandCollection[i] != null)
                    {
                        this.CommandCollection[i].Connection = value;
                    }
                }
            }
        }
    }
}

